package com.shop.web;

import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.shop.entity.User;
import com.shop.service.UserService;

public class UserAction extends ActionSupport{
	
	private User user ;
	@Autowired
	private UserService userService ;
	
	public String register(){
		System.out.println("=="+user);
		userService.saveUser(user);
		return "login";
	}
	public String login(){
		User myuser = userService.login(user);
	//	System.out.println(",,,,,,,,,,"+myuser+",,,,,");
		if(myuser != null){
			ActionContext.getContext().getSession().put("myuser", myuser);
			return "login_success";
		}else{
			System.out.println("-------登录失败！-------");
			return "login";
		}
	}
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	
	

}
